package temp.class_hierarchy;

import org.junit.Test;

/**
 * Created by admin on 2016-11-9.
 */
class Gen<T> {

    private T ob;

    Gen(T o){
        ob=o;
    }

    T getOb(){
        return ob;
    }
}

class Gen2<T> extends Gen{

    Gen2(T o){
        super(o);
    }
}
public class HierDemo{


    @Test
    public void test(){
        Gen<Integer> iOb=new Gen<>(88);
        Gen2<Integer> iOb2=new Gen2<>(99);

        Gen2<String> strOb2=new Gen2<>("test");

        if(iOb2 instanceof Gen2<?>){
            System.out.println("iob2 is gen2");
        }

        if(iOb2 instanceof Gen<?>){
            System.out.println("iob2 is gen");
        }

        if(strOb2 instanceof Gen2<?>){
            System.out.println("strOb2 is gen2");
        }

        if(strOb2 instanceof Gen<?>){
            System.out.println("strOb2 is gen");
        }

        if(iOb instanceof Gen2<?>){
            System.out.println("iob is gen2");
        }

        if(iOb instanceof Gen<?>){
            System.out.println("iob is gen");
        }

//        if(iOb2 instanceof Gen2<Integer>){
//            System.out.println("iob2 is gen2");
//        }
    }

}